package com.gg.fmallspringboot.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/* stohox
2021/6/19 11:07 */
@Configuration
@EnableKnife4j
@EnableSwagger2   // 开启swagger文档
public class SwaggerConfig {
    @Bean
    public Docket docket(){
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("锋迷商城接口文档")
                .version("v1.0")
                .description("前后端交互接口文档管理界面")
                .contact(new Contact("wangyiyun","http://localhost:8080/","wangyiyun.@163.com"))
                .build();

        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .select()   // 开始选择公布那些接口
                .apis(RequestHandlerSelectors.basePackage("com.gg.fmallspringboot.controller"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(HttpSession.class, MultipartFile.class, HttpServletRequest.class);  // 获取掉 HttpSession, MultipartFile, HttpServletRequest.
        return docket;
    }
}
